<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户反馈</el-breadcrumb-item>
    </el-breadcrumb>
    <el-table
      size="small"
      :data="fbackList"
      highlight-current-row
      v-loading="loading"
      border
      element-loading-text="拼命加载中"
      style="width: 100%"
    >
      <el-table-column align="center" type="index" width="60">
      </el-table-column>
      <el-table-column
        prop="ufNo"
        label="订单编号"
        width="120"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="userName"
        label="用户名称"
        width="120"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="userTel"
        label="用户电话"
        width="120"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="ufContent"
        label="反馈内容"
        width="120"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="ufTime"
        label="反馈时间"
        width="150"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="reservedInt"
        label="状态"
        width="120"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          <span v-if="scope.row.reservedInt == 0">未处理</span>
          <span v-if="scope.row.reservedInt == 1">已处理</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="reservedVar"
        label="处理内容"
        width="150"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column align="center" label="操作" min-width="300">
        <template slot-scope="scope">
          <el-button
            v-if="scope.row.reservedInt == 0"
            size="mini"
            @click="updateStatus(scope.row.ufId)"
            >处理</el-button
          >
          <el-button
            v-if="scope.row.reservedInt == 1"
            size="mini"
            @click="updateStatus(scope.row.ufId)"
            disabled
            >已处理</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-dialog title="反馈处理" :visible.sync="dialog.updateshow" width="30%">
      <el-form :model="form">
        <el-form-item label="处理结果反馈" :label-width="formLabelWidth">
          <el-input type="textarea" v-model="reservedVar"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialog.updateshow = false">取 消</el-button>
        <el-button type="primary" @click="update()">提 交</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ufId:"",
      reservedVar:"",
      reservedInt:"",
      fbackList: [],
      loading: false,
      dialog:{
        updateshow:false,
      }
    };
  },
  methods: {
    update(){
      this.$axios.post("fback/chuli",{
        ufId:this.ufId,
        reservedVar:this.reservedVar,
        reservedInt:1
      })
      .then(res => {
        if(res.data.code == 200){
            this.$message.success("处理成功");
            this.dialog.updateshow  = false;
            this.selAll();
        }
      })  
    },
    updateStatus(ufId){
        this.dialog.updateshow = true;
        this.ufId = ufId;
    },
    selAll() {
      this.$axios.get("/fback").then((res) => {
        this.fbackList = res.data.data.fbackList;
      });
    },
  },
  mounted() {
    this.selAll();
  },
};
</script>